package com.tianci.appstore.ui.widget;

import android.content.Context;

import com.tianci.appstore.ui.data.SkyListAppData.ListType;
import com.tianci.appstore.ui.list.ListBlock;
import com.tianci.appstore.ui.list.ListProgressBlock;
import com.tianci.appstore.ui.list.ListSelectedBlock;
import com.tianci.appstore.ui.list.ListStatusBlock;
import com.tianci.appstore.ui.list.ListSwitchBlock;
import com.tianci.appstore.ui.list.ListUninstallBlock;
import com.tianci.appstore.ui.mainpage.ContactBlock;
import com.tianci.appstore.ui.mainpage.MainBigBlock;
import com.tianci.appstore.ui.mainpage.MainCgyBlock;
import com.tianci.appstore.ui.mainpage.MainSmallBlock;
import com.tianci.appstore.ui.mainpage.ManageBlock;
import com.tianci.appstore.ui.search.SearchListBlock;

public class BlockFactory {
    public enum BlockType {
        SND_CGY_BLOCK,
        BIG_RMD_BLOCK,
        SMALL_RMD_BLOCK,
        LIST_BLOCK,
        FUNC_BLOCK,
        QR_CODE
    }

    ;

    public static SkyBaseItemView createBlock(Context context, BlockType blockType) {
        SkyBaseItemView itemView = null;
        switch (blockType) {
            case SND_CGY_BLOCK:
                itemView = new MainCgyBlock(context);
                break;
            case BIG_RMD_BLOCK:
                itemView = new MainBigBlock(context);
                break;
            case SMALL_RMD_BLOCK:
                itemView = new MainSmallBlock(context);
                break;
            case LIST_BLOCK:
                itemView = new ListBlock(context, ListType.LOCAL_APP_LIST);
                break;
            case FUNC_BLOCK:
                itemView = new ManageBlock(context);
                break;
            case QR_CODE:
                itemView = new ContactBlock(context);
                break;
            default:
                break;
        }
        return itemView;
    }

    public static ListBlock createListBlock(Context context, ListType listType) {
        ListBlock block = null;
        switch (listType) {
            case CGY_APP_LIST:
            case APK_SCAN_LIST:
                block = new ListStatusBlock(context, listType);
                break;
            case UNINSTALL_APP_LIST:
                block = new ListUninstallBlock(context, listType);
                break;
            case CLEAR_CACHE_LIST:
            case LOCAL_APP_LIST:
            case MOVE_APP_LIST:
                block = new ListBlock(context, listType);
                break;
            case UPGRADE_APP_LIST:
            case DOWNLOAD_LIST:
                block = new ListProgressBlock(context, listType);
                break;
            case SEARCH_LIST:
                block = new SearchListBlock(context, listType);
                break;
            case SEARCH_HOT_LIST:
                SearchListBlock searchListBlock = new SearchListBlock(context, listType);
                searchListBlock.setIsSearchHotItem(true);
                block = searchListBlock;
                break;
            case LAUNCH_ON_BOOT_LIST:
                block = new ListSwitchBlock(context, listType);
                break;
            case SELECTED_LAUNCH_LIST:
                block = new ListSelectedBlock(context, listType);
                break;
        }
        return block;
    }
}
